Skip to content

Use new MSVC preprocessor for VS 17 builds #15201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Aug 2, 2024

From the documentation[1]:

| We're updating the Microsoft C++ preprocessor to improve standards | conformance, fix longstanding bugs, and change some behaviors that | are officially undefined. We've also added new diagnostics to warn | on errors in macro definitions.

Thus it appears to be sensible to switch to the new preprocessor for all VS17 builds. Note that although the new preprocessor is available as of VS16.5 (i.e. version >= 1925), we don't want to potentially break older builds, and as such use the new preprocessor only for VS17 builds. Users who wish to use the new preprocessor with VS16, can still set CFLAGS=/Zc:preprocessor before running buildconf/phpize.

[1] https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170


Note that I was reminded of this when re-checking krakjoe/cmark#20, and the new preprocessor was quite helpful in directly triggering a useful C5101 diagnostic, instead of triggering C2121 and C2059.

This change might break builds of older PHP versions with VS17, but those users can counteract via set CFLAGS=/Zc:preprocessor-, or just fix the code for best (forward) compatibility.

From the documentation[1]:

| We're updating the Microsoft C++ preprocessor to improve standards
| conformance, fix longstanding bugs, and change some behaviors that
| are officially undefined. We've also added new diagnostics to warn
| on errors in macro definitions.

Thus it appears to be sensible to switch to the new preprocessor for
all VS17 builds.  Note that although the new preprocessor is available
as of VS16.5 (i.e. `version >= 1925`), we don't want to potentially
break older builds, and as such use the new preprocessor only for VS17
builds.  Users who wish to use the new preprocessor with VS16, can
still `set CFLAGS=/Zc:preprocessor` before running `buildconf`/`phpize`.

[1] <https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170>
@cmb69
Copy link
Member Author

cmb69 commented Aug 2, 2024

I need to check the failing test on Windows. Back to draft for now.

@cmb69 cmb69 marked this pull request as draft August 2, 2024 12:26
@cmb69
Copy link
Member Author

cmb69 commented Aug 2, 2024

Windows test failure was intermittend; the Travis build fails for the usual reasons.

@cmb69 cmb69 marked this pull request as ready for review August 2, 2024 13:30
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSTM to use the new C compliant preprocessor

@cmb69 cmb69 closed this in d5c4522 Aug 6, 2024
@cmb69 cmb69 deleted the cmb/new-preproc branch August 6, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants